//
//  ClockModel.m
//  tEngineTechDemo
//
//  Created by Gareth Williams on 16/01/2012.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "ClockModel.h"

@interface ClockModel()

@property(readonly, nonatomic) float intervalInSeconds;

@end

@implementation ClockModel

@synthesize FPS = _FPS;
@synthesize current_T = _current_T;
@synthesize clockMultiplier;

@synthesize intervalInSeconds = _intervalInSeconds;

-(id)initWithFPS:(int)framesPerSecond
{
    [self setFPS:framesPerSecond];
    return [self init];
}

- (id)init 
{
    self = [super init];
    if (self) 
    {
        _current_T = 0.0;
        clockMultiplier = 1.0;
    }
    return self;
}

#pragma mark accessors

-(void)setFPS:(int)framesPerSecond
{
    _FPS = framesPerSecond;
    _intervalInSeconds = 1.0f/_FPS;
}

#pragma mark -

-(float)update
{
    _current_T += _intervalInSeconds * clockMultiplier;
    
    return _current_T;
}

@end
